//
//  YQAddressBottomView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQAddressBottomView.h"

@implementation YQAddressBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupBtnView];
    }
    return self;
}

- (void)setupBtnView {
    [self addSubview:self.importWalletBtn];
    [self addSubview:self.createWalletBtn];
    [self addSubview:self.chooseBtn];
    [self addSubview:self.describeLab];
    [self addSubview:self.serverBtn];
    
    [self.importWalletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(18));
        make.bottom.mas_equalTo(-FIT(10));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(36), kButtonHeight));
    }];
    
    [self.createWalletBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(18));
        make.bottom.equalTo(self.importWalletBtn.mas_top).mas_equalTo(-FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(36), kButtonHeight));
    }];
    
    [self.chooseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(18));
        make.bottom.equalTo(self.createWalletBtn.mas_top).mas_equalTo(-FIT(20));
        make.size.mas_equalTo(CGSizeMake(FIT(15), FIT(15)));
    }];

    [self.describeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.chooseBtn.mas_right).mas_equalTo(FIT(5));
        make.centerY.equalTo(self.chooseBtn.mas_centerY);
    }];

    [self.serverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.describeLab.mas_right).mas_equalTo(FIT(5));
        make.centerY.equalTo(self.chooseBtn.mas_centerY);
    }];
}

- (UIButton *)importWalletBtn {
    if (!_importWalletBtn) {
        _importWalletBtn = [YQViewFactory buttonWithTitle:@"导入钱包" titleColor:MainBlackColor fontSize:kCellFont userBold:NO target:self sel:@selector(importAction)];
        _importWalletBtn.backgroundColor = UIColorFromRGB(0x999db7);
        _importWalletBtn.layer.cornerRadius = 3;
        
    }
    return _importWalletBtn;
}

- (UIButton *)createWalletBtn {
    if (!_createWalletBtn) {
        _createWalletBtn = [YQViewFactory buttonWithTitle:@"创建钱包" titleColor:WhiteColor fontSize:kCellFont userBold:NO target:self sel:@selector(createAction)];
        _createWalletBtn.backgroundColor = MainBlueColor;
        _createWalletBtn.layer.cornerRadius = 3;

    }
    return _createWalletBtn;
}

- (UIButton *)chooseBtn {
    if (!_chooseBtn) {
        _chooseBtn = [YQViewFactory buttonWithImage:YQ_IMAGE(@"") target:self sel:@selector(chooseAction:)];
        [_chooseBtn setImage:YQ_IMAGE(@"") forState:UIControlStateSelected];
        [_chooseBtn setBackgroundColor:MainRedTextColor];
    }
    return _chooseBtn;
}

- (UILabel *)describeLab {
    if (!_describeLab) {
        _describeLab = [YQViewFactory labelWithTextColor:[UIColor grayColor] textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _describeLab.text = @"我已仔细阅读并同意";
    }
    return _describeLab;
}

- (UIButton *)serverBtn {
    if (!_serverBtn) {
        _serverBtn = [YQViewFactory buttonWithTitle:@"《服务及隐私条款》" titleColor:MainBlueColor fontSize:kLittleFont userBold:NO target:self sel:@selector(serverAction)];
    }
    return _serverBtn;
}

#pragma mark - action
- (void)importAction {
    
}

- (void)createAction {
    if (self.CreateWalletBlock) {
        self.CreateWalletBlock();
    }
}

- (void)chooseAction:(UIButton *)sender {
    sender.selected = !sender.selected;
}

- (void)serverAction {
    //点击展开View
}

@end
